package yzx.common.view.util;

import android.graphics.Point;
import android.support.v7.widget.RecyclerView;

public class RecyclerViewUtil {

    public interface OnRangeChangedListener{
        void onScrollRangeChange(int totalDx, int totalDy);
    }


    public static void bindScrollRange(RecyclerView view, final OnRangeChangedListener listener){
        final Point value = new Point(0, 0);
        view.addOnScrollListener(new RecyclerView.OnScrollListener() {
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                value.x += dx;
                value.y += dy;
                listener.onScrollRangeChange(value.x, value.y);
            }
        });
    }

}
